<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="RAIDRedundant Array of Independent Disks 独立硬盘冗余阵列,旧称廉价磁盘冗余阵列.简称磁盘阵列。利用虚拟化存储技术把多个硬盘组合起来，成为一个或多个硬盘阵列组，目的为提升性能或数据冗余，或是两者同时提升。 在运作中，取决于 RAID 层级不同，数据会以多种模式分散于各个硬盘，RAID 层级的命名会以 RAID 开头并带数字，例如：RAID 0、RAID 1、">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux平台RAID">
<meta property="og:url" content="http://yoursite.com/2020/05/06/3-Linux%E5%B9%B3%E5%8F%B0RAID/index.html">
<meta property="og:site_name" content="Lcxiao&#39;s blog">
<meta property="og:description" content="RAIDRedundant Array of Independent Disks 独立硬盘冗余阵列,旧称廉价磁盘冗余阵列.简称磁盘阵列。利用虚拟化存储技术把多个硬盘组合起来，成为一个或多个硬盘阵列组，目的为提升性能或数据冗余，或是两者同时提升。 在运作中，取决于 RAID 层级不同，数据会以多种模式分散于各个硬盘，RAID 层级的命名会以 RAID 开头并带数字，例如：RAID 0、RAID 1、">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/RAID_0.svg/130px-RAID_0.svg.png">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/RAID_1.svg/130px-RAID_1.svg.png">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b5/RAID2_arch.svg/300px-RAID2_arch.svg.png">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/RAID_3.svg/220px-RAID_3.svg.png">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/RAID_4.svg/220px-RAID_4.svg.png">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/6/64/RAID_5.svg/220px-RAID_5.svg.png">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/RAID_6.svg/270px-RAID_6.svg.png">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e2/JBOD.svg/175px-JBOD.svg.png">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/b/bb/RAID_10.svg/220px-RAID_10.svg.png">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/RAID_01.svg/220px-RAID_01.svg.png">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/RAID_50.png/500px-RAID_50.png">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Raid_60.jpg/300px-Raid_60.jpg">
<meta property="article:published_time" content="2020-05-06T05:23:39.000Z">
<meta property="article:modified_time" content="2020-05-06T13:58:39.383Z">
<meta property="article:author" content="lcxiao">
<meta property="article:tag" content="磁盘">
<meta property="article:tag" content="linux">
<meta property="article:tag" content="文件系统">
<meta property="article:tag" content="RAID">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/RAID_0.svg/130px-RAID_0.svg.png">

<link rel="canonical" href="http://yoursite.com/2020/05/06/3-Linux%E5%B9%B3%E5%8F%B0RAID/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Linux平台RAID | Lcxiao's blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="Lcxiao's blog" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Lcxiao's blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-lifestyle">

    <a href="/lifestyle/" rel="section"><i class="fa fa-fw fa-lifestyle"></i>LifeStyle</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2020/05/06/3-Linux%E5%B9%B3%E5%8F%B0RAID/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="lcxiao">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Lcxiao's blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Linux平台RAID
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2020-05-06 13:23:39 / 修改时间：21:58:39" itemprop="dateCreated datePublished" datetime="2020-05-06T13:23:39+08:00">2020-05-06</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Linux/" itemprop="url" rel="index"><span itemprop="name">Linux</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="RAID"><a href="#RAID" class="headerlink" title="RAID"></a>RAID</h1><p><code>R</code>edundant <code>A</code>rray of <code>I</code>ndependent <code>D</code>isks <code>独立硬盘冗余阵列</code>,旧称<code>廉价磁盘冗余阵列</code>.<br>简称<code>磁盘阵列</code>。利用虚拟化存储技术把多个硬盘组合起来，成为一个或多个硬盘阵列组，目的为提升性能或数据冗余，或是两者同时提升。</p>
<p>在运作中，取决于 RAID 层级不同，数据会以多种模式分散于各个硬盘，RAID 层级的命名会以 RAID 开头并带数字，例如：RAID 0、RAID 1、RAID 5、RAID 6、RAID 7、RAID 01、RAID 10、RAID 50、RAID 60。每种等级都有其理论上的优缺点，不同的等级在两个目标间获取平衡，分别是增加数据可靠性以及增加存储器（群）读写性能。</p>
<p>简单来说，RAID把多个硬盘组合成为一个逻辑硬盘，因此，操作系统只会把它当作一个实体硬盘。RAID常被用在服务器电脑上，并且常使用完全相同的硬盘作为组合。由于硬盘价格的不断下降与RAID功能更加有效地与主板集成，它也成为普通用户的一个选择，特别是需要大容量存储空间的工作，如：视频与音频制作。</p>
<table>
<thead>
<tr>
<th>RAID等级</th>
<th>最少硬盘</th>
<th>最大容错</th>
<th>可用容量</th>
<th>读取性能</th>
<th>写入性能</th>
<th>安全性</th>
<th>目的</th>
<th>应用产业</th>
</tr>
</thead>
<tbody><tr>
<td>0</td>
<td>2</td>
<td>0</td>
<td>n</td>
<td>n</td>
<td>n</td>
<td>一个硬盘异常，全部硬盘都会异常</td>
<td>追求最大容量、速度</td>
<td>影片剪接缓存用途</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>n-1</td>
<td>1</td>
<td>n</td>
<td>1</td>
<td>高，一个正常即可</td>
<td>追求最大安全性</td>
<td>个人、企业备份</td>
</tr>
<tr>
<td>5</td>
<td>3</td>
<td>1</td>
<td>n-1</td>
<td>n-1</td>
<td>n-1</td>
<td>高</td>
<td>追求最大容量、最小预算</td>
<td>个人、企业备份</td>
</tr>
<tr>
<td>6</td>
<td>4</td>
<td>2</td>
<td>n-2</td>
<td>n-2</td>
<td>n-2</td>
<td>安全性较RAID 5高</td>
<td>同RAID 5，但较安全</td>
<td>个人、企业备份</td>
</tr>
<tr>
<td>10</td>
<td>4</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>高</td>
<td>综合RAID 0/1优点，理论速度较快</td>
<td>大型数据库、服务器</td>
</tr>
<tr>
<td>50</td>
<td>6</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>高</td>
<td>提升数据安全</td>
<td></td>
</tr>
<tr>
<td>60</td>
<td>8</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>高</td>
<td>提升数据安全</td>
<td></td>
</tr>
<tr>
<td>单一硬盘</td>
<td>(参考)</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>无</td>
<td></td>
<td></td>
</tr>
<tr>
<td>jBOD</td>
<td>1</td>
<td>0</td>
<td>n</td>
<td>1</td>
<td>1</td>
<td>无（同RAID 0）</td>
<td>增加容量</td>
<td>个人（暂时）存储备份</td>
</tr>
</tbody></table>
<h2 id="标准RAID"><a href="#标准RAID" class="headerlink" title="标准RAID"></a>标准RAID</h2><h3 id="参数说明"><a href="#参数说明" class="headerlink" title="参数说明"></a>参数说明</h3><pre><code>1. n代表硬盘总数
2. JBOD（Just a Bunch Of Disks）指将数个物理硬盘，在操作系统中合并成一个逻辑硬盘，以直接增加容量
3. 依不同 RAID 厂商实现算法对于性能表现会有不同，性能公式仅供参考
4. RAID 10、50、60 依实现 Parity 不同公式也不同</code></pre><h3 id="RAID-0"><a href="#RAID-0" class="headerlink" title="RAID 0"></a>RAID 0</h3><p>它将两个以上的磁盘并联起来，成为一个大容量的磁盘。在存放数据时，分段后分散存储在这些磁盘中，因为读写时都可以并行处理，所以在所有的级别中，<code>RAID 0的速度是最快的</code>。但是<code>RAID 0既没有冗余功能</code>，也<code>不具备容错能力</code>，如果一个磁盘（物理）损坏，所有数据都会丢失。</p>
<p>读写性能提升：<br>可用空间：N*min(S1,S2…)<br>无容错能力<br>最小磁盘数:2</p>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/RAID_0.svg/130px-RAID_0.svg.png" alt=""></p>
<h3 id="RAID-1"><a href="#RAID-1" class="headerlink" title="RAID 1"></a>RAID 1</h3><p>两组以上的N个磁盘相互作镜像，在一些多线程操作系统中能有很好的读取速度，<code>理论上读取速度等于硬盘数量的倍数</code>，与RAID 0相同。另外<code>写入速度有微小的降低</code>。只要一个磁盘正常即可维持运作，<code>可靠性最高</code>。其原理为在主硬盘上存放数据的同时也在镜像硬盘上写一样的数据。当主硬盘（物理）损坏时，镜像硬盘则代替主硬盘的工作。因为有镜像硬盘做数据备份，所以<code>RAID 1的数据安全性在所有的RAID级别上来说是最好的</code>。但无论用多少磁盘做RAID 1，仅算一个磁盘的容量，是所有RAID中<code>磁盘利用率最低的一个级别</code>。</p>
<p>读性能提升、写性能略微下降：<br>可用空间：1*min(S1,S2…)<br>有冗余能力<br>最少磁盘数：2</p>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/RAID_1.svg/130px-RAID_1.svg.png" alt=""></p>
<h3 id="RAID-2-不常见"><a href="#RAID-2-不常见" class="headerlink" title="RAID 2 (不常见)"></a>RAID 2 (不常见)</h3><p>这是RAID 0的改良版，以汉明码（Hamming Code）的方式将数据进行编码后分割为独立的比特，并将数据分别写入硬盘中。因为在数据中加入错误修正码（ECC，Error Correction Code），所以数据整体的容量会比原始数据大一些。</p>
<p>RAID 2最少要三台磁盘驱动器方能运作。<br><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b5/RAID2_arch.svg/300px-RAID2_arch.svg.png" alt=""></p>
<h3 id="RAID-3-不常见"><a href="#RAID-3-不常见" class="headerlink" title="RAID 3 (不常见)"></a>RAID 3 (不常见)</h3><p>采用Bit－interleaving（数据交错存储）技术，它需要通过编码再将数据比特分割后分别存在硬盘中，而将同比特检查后单独存在一个硬盘中，但由于数据内的比特分散在不同的硬盘上，因此就算要读取一小段数据资料都可能需要所有的硬盘进行工作，所以这种规格比较适于读取大量数据时使用。<br><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/RAID_3.svg/220px-RAID_3.svg.png" alt=""></p>
<h3 id="RAID-4"><a href="#RAID-4" class="headerlink" title="RAID 4"></a>RAID 4</h3><p>它与RAID 3不同的是它在分割时是以区块为单位分别存在硬盘中，但每次的数据访问都必须从同比特检查的那个硬盘中取出对应的同比特数据进行核对，由于过于频繁的使用，所以对硬盘的损耗可能会提高。（块交织技术，Block interleaving）<br>1101,0110,1011</p>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/RAID_4.svg/220px-RAID_4.svg.png" alt=""></p>
<h3 id="RAID-5"><a href="#RAID-5" class="headerlink" title="RAID 5"></a>RAID 5</h3><p>RAID Level 5是一种储存性能、数据安全和存储成本兼顾的存储解决方案。它使用的是Disk Striping（硬盘分割）技术。</p>
<p>RAID 5至少需要三个硬盘，RAID 5不是对存储的数据进行备份，而是把数据和相对应的奇偶校验信息存储到组成RAID5的各个磁盘上，并且奇偶校验信息和相对应的数据分别存储于不同的磁盘上。当RAID5的一个磁盘数据发生损坏后，可以利用剩下的数据和相应的奇偶校验信息去恢复被损坏的数据。RAID 5可以理解为是RAID 0和RAID 1的折衷方案。RAID 5可以为系统提供数据安全保障，但保障程度要比镜像低而磁盘空间利用率要比镜像高。RAID 5具有和RAID 0相近似的数据读取速度，只是因为多了一个奇偶校验信息，写入数据的速度相对单独写入一块硬盘的速度略慢，若使用“回写缓存”可以让性能改善不少。同时由于多个数据对应一个奇偶校验信息，RAID 5的磁盘空间利用率要比RAID 1高，存储成本相对较便宜。</p>
<p>读写性能提升<br>可用空间：(N-1)*min(S1,S2…)<br>有容错能力，1块硬盘<br>最少磁盘数3</p>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/64/RAID_5.svg/220px-RAID_5.svg.png" alt=""></p>
<h3 id="RAID-6"><a href="#RAID-6" class="headerlink" title="RAID 6"></a>RAID 6</h3><p>读写性能提升<br>可用空间：(N-2)*min(S1,S2…)<br>有容错能力，2块硬盘<br>最少磁盘数4</p>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/RAID_6.svg/270px-RAID_6.svg.png" alt=""></p>
<h2 id="混合RAID"><a href="#混合RAID" class="headerlink" title="混合RAID"></a>混合RAID</h2><h3 id="JBOD"><a href="#JBOD" class="headerlink" title="JBOD"></a>JBOD</h3><p>just a bunch of disks<br>功能：将多块硬盘的空间合并一个大的连续空间使用；<br>可用功能：sum(S1,S2…)<br><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e2/JBOD.svg/175px-JBOD.svg.png" alt=""></p>
<h3 id="RAID-10"><a href="#RAID-10" class="headerlink" title="RAID 10"></a>RAID 10</h3><p>读写性能提升<br>可用空间：N*min(S1,S2…)/2<br>有容错能力：每组镜像最多只能坏一块；<br>最少磁盘数4</p>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/bb/RAID_10.svg/220px-RAID_10.svg.png" alt=""></p>
<h3 id="RAID-01"><a href="#RAID-01" class="headerlink" title="RAID 01"></a>RAID 01</h3><p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/RAID_01.svg/220px-RAID_01.svg.png" alt=""></p>
<h3 id="RAID-50"><a href="#RAID-50" class="headerlink" title="RAID 50"></a>RAID 50</h3><p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/RAID_50.png/500px-RAID_50.png" alt=""></p>
<h3 id="RAID-60"><a href="#RAID-60" class="headerlink" title="RAID 60"></a>RAID 60</h3><p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Raid_60.jpg/300px-Raid_60.jpg" alt=""></p>
<h2 id="应用"><a href="#应用" class="headerlink" title="应用"></a>应用</h2><p>RAID2、3、4较少实际应用，因为RAID0、RAID1、RAID5、RAID6和混合RAID已经涵盖所需的功能，因此RAID2、3、4大多只在研究领域有实现，而实际应用上则以RAID0、RAID1、RAID5、RAID6和混合RAID为主。</p>
<p>RAID4有应用在某些商用机器上，像是NetApp公司设计的NAS系统就是使用RAID4的设计概念。</p>
<h2 id="种类"><a href="#种类" class="headerlink" title="种类"></a>种类</h2><p>根据实现模式，分为软件和硬件两种：<br><code>CentOS6</code>上面 软件方式实现：<br>结合内核中的<code>md(multi devices)</code><br><code>mdadm</code> 模式化的工具</p>
<p>命令的语法格式： <code>mdadm [mode] &lt;raiddevice&gt; [options] &lt;componet-devices&gt;</code><br>支持的RAID级别：<code>LINEAR,RAID0,RAID1,RAID4,RAID5,RAID6,RAID10</code>;</p>
<p>模式：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">创建： -C</span><br><span class="line">装配： -A</span><br><span class="line">监控： -F</span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">管理： -f， -r， -a</span><br><span class="line">    &lt;raiddevice&gt;: &#x2F;dev&#x2F;md#</span><br><span class="line">    &lt;component-devices&gt;: 任意块设备</span><br><span class="line"></span><br><span class="line">-C: 创建模式：</span><br><span class="line">    -n #: 使用#个块设备来创建此RAID；</span><br><span class="line">    -l #: 指明要创建的RAID的级别；</span><br><span class="line">    -a:  &#123;yes| no&#125; 自动创建目标RAID设备的设备文件；</span><br><span class="line">    -c: CHUNK_SIZE 指定块大小</span><br><span class="line">    -x: 指明空闲盘的个数</span><br></pre></td></tr></table></figure>

<p><strong>例如：创建一个10G可用空间的RAID5；</strong></p>
<p>创建<br><code>mdadm -C /dev/md0 -a yes -n 3 -x 1 -l 5 /devsda{7,8,9,10}</code><br>格式化<br><code>mkfs -v -t ext4 /dev/md0</code><br>挂载使用：<br><code>mount /dev/md0 MOUNT_POINT</code></p>
<p><strong>显示设备信息:</strong><br>-D：显示RAID的详细信息；<br><code>mdadm -D /dev/md#</code></p>
<p><strong>管理模式：</strong><br>-f 标记指定磁盘为损坏；<br><code>mdadm /dev/md0 -fdev/sda#</code></p>
<p>-a 添加磁盘<br><code>mdadm /dev/md0 -adev/sda#</code></p>
<p>-r 移除磁盘<br><code>mdadm /dev/md0 -rdev/sda#</code></p>
<p>观察md的状态；<br><code>cat /proc/mdstat</code></p>
<p>停止md设备<br><code>mdadm -S /dev/md#</code></p>
<p><strong>先卸载设备</strong><br><code>umount /dev/md0</code><br><code>mdadm -S /dev/md0</code></p>
<p>watch 命令：<br><code>-n # 刷新间隔，单位是秒</code><br><code>watch -n# &quot;command&quot;</code></p>
<p>练习1：创建一个可用空间为10G的RAID1设备，要求其chunk大小为128k，文件系统为ext4，有一个空闲盘，开机可自动挂载至/backup目录；</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mdadm -C /dev/md0 -c 128K -x 1 -n 2 -l 1 -a yes /deb/sda&#123;5,6,7&#125;</span><br><span class="line">mkfs -v -t ext4</span><br><span class="line"><span class="built_in">echo</span> <span class="string">"`blkid /dev/md0 | awk '&#123;print <span class="variable">$3</span>&#125;'` /backup ext4 defaults 0 0"</span> &gt;&gt; /etc/fstab</span><br></pre></td></tr></table></figure>

<p>练习2：创建一个可用空间为10G的RAID10设备，要求chunk大小为256k，文件系统为ext4，开机可自动挂载至/mydata目录；</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mdadm -C /dev/md0 -c 256K -n 4 -l 10 -a yes /dev/sdb&#123;7,8,9,10&#125;</span><br><span class="line">mkfs -v -t ext4</span><br><span class="line"><span class="built_in">echo</span> <span class="string">"`blkid /dev/md0 | awk '&#123;print <span class="variable">$3</span>&#125;'` /mydata ext4 defaults 0 0"</span> &gt;&gt; /etc/fstab</span><br></pre></td></tr></table></figure>

<h3 id="磁盘阵列相关客户类型"><a href="#磁盘阵列相关客户类型" class="headerlink" title="磁盘阵列相关客户类型"></a>磁盘阵列相关客户类型</h3><ul>
<li>一般消费者备份数据之用、企业创建ERP系统或NAS系统时的重要数据备份。</li>
<li>影音多媒体数字内容创作公司、个人影音剪辑数字内容工作室、摄影工作室、摄影公司。</li>
<li>电视台、广播电台及互联网内容提供商等传统媒体及新媒体。</li>
<li>数字监控系统（DVR）、网络监控系统（NVR）等等需要大量存储影片的监控系统业者，军方、赌场因为需要大量监控系统也是常见使用磁盘阵列的客户。</li>
<li>证券、银行等金融行业保管重要客户数据。</li>
</ul>
<h2 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h2><p><a href="https://wiki.archlinux.org/index.php/RAID_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)" target="_blank" rel="noopener">Arch Wiki</a></p>
<h2 id="常用级别："><a href="#常用级别：" class="headerlink" title="常用级别："></a>常用级别：</h2><p>RAID-0、RAID-1、RAID-5、RAID-10、RAID-50、JBOD</p>
<h2 id="RAID各级别特性"><a href="#RAID各级别特性" class="headerlink" title="????RAID各级别特性"></a>????RAID各级别特性</h2>
    </div>

    
    
    
        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E7%A3%81%E7%9B%98/" rel="tag"># 磁盘</a>
              <a href="/tags/linux/" rel="tag"># linux</a>
              <a href="/tags/%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/" rel="tag"># 文件系统</a>
              <a href="/tags/RAID/" rel="tag"># RAID</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/05/06/101-progit/" rel="prev" title="progit">
      <i class="fa fa-chevron-left"></i> progit
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/05/31/4-Linux%E5%AE%9E%E7%8E%B0LVM%E9%80%BB%E8%BE%91%E5%8D%B7%E5%8F%8A%E5%BF%AB%E7%85%A7/" rel="next" title="Linux实现LVM逻辑卷及快照">
      Linux实现LVM逻辑卷及快照 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#RAID"><span class="nav-number">1.</span> <span class="nav-text">RAID</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#标准RAID"><span class="nav-number">1.1.</span> <span class="nav-text">标准RAID</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#参数说明"><span class="nav-number">1.1.1.</span> <span class="nav-text">参数说明</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#RAID-0"><span class="nav-number">1.1.2.</span> <span class="nav-text">RAID 0</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#RAID-1"><span class="nav-number">1.1.3.</span> <span class="nav-text">RAID 1</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#RAID-2-不常见"><span class="nav-number">1.1.4.</span> <span class="nav-text">RAID 2 (不常见)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#RAID-3-不常见"><span class="nav-number">1.1.5.</span> <span class="nav-text">RAID 3 (不常见)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#RAID-4"><span class="nav-number">1.1.6.</span> <span class="nav-text">RAID 4</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#RAID-5"><span class="nav-number">1.1.7.</span> <span class="nav-text">RAID 5</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#RAID-6"><span class="nav-number">1.1.8.</span> <span class="nav-text">RAID 6</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#混合RAID"><span class="nav-number">1.2.</span> <span class="nav-text">混合RAID</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#JBOD"><span class="nav-number">1.2.1.</span> <span class="nav-text">JBOD</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#RAID-10"><span class="nav-number">1.2.2.</span> <span class="nav-text">RAID 10</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#RAID-01"><span class="nav-number">1.2.3.</span> <span class="nav-text">RAID 01</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#RAID-50"><span class="nav-number">1.2.4.</span> <span class="nav-text">RAID 50</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#RAID-60"><span class="nav-number">1.2.5.</span> <span class="nav-text">RAID 60</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#应用"><span class="nav-number">1.3.</span> <span class="nav-text">应用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#种类"><span class="nav-number">1.4.</span> <span class="nav-text">种类</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#磁盘阵列相关客户类型"><span class="nav-number">1.4.1.</span> <span class="nav-text">磁盘阵列相关客户类型</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#参考"><span class="nav-number">1.5.</span> <span class="nav-text">参考</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#常用级别："><span class="nav-number">1.6.</span> <span class="nav-text">常用级别：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#RAID各级别特性"><span class="nav-number">1.7.</span> <span class="nav-text">????RAID各级别特性</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">lcxiao</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">38</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
        <span class="site-state-item-count">1</span>
        <span class="site-state-item-name">分类</span>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">9</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://163.com/" title="http:&#x2F;&#x2F;163.com" rel="noopener" target="_blank">163</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="http://baidu.com/" title="http:&#x2F;&#x2F;baidu.com" rel="noopener" target="_blank">baidu</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="/dalipan.com" title="dalipan.com">dalipan</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="https://google.com/" title="https:&#x2F;&#x2F;google.com" rel="noopener" target="_blank">Google</a>
        </li>
    </ul>
  </div>

      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">lcxiao</span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
